<?php

class SectionOrderForm extends CFormModel {

	public $begin_num = 100;	//开始数值
	public $setp_num = 1;	//步长

	public function rules() {
		return array(
			array('begin_num, setp_num', 'required'),
			array('begin_num, setp_num', 'numerical', 'integerOnly'=>true),
			array('begin_num', 'rangeValidators', 'min'=>100),
			array('setp_num', 'rangeValidators', 'min'=>1),
		);
	}

	public function attributeLabels() {
		return array(
			'begin_num'=>'开始数值',
			'setp_num'=>'步长',
		);
	}

	public function rangeValidators($attribute,$params)
	{
		$_attributeLabels = $this->attributeLabels();
		if(!$this->hasErrors())
		{
			$_value = $this->$attribute;
			if (isset($params['min']) && $params['min']>$_value) {
				$this->addError($attribute, $_attributeLabels[$attribute].'不能小于'.$params['min']);
			}
			else if (isset($params['max']) && $params['max']<$_value) {
				$this->addError($attribute, $_attributeLabels[$attribute].' 不能大于'.$params['max']);
			}
		}
	}


}
?>
